package leetcode;

public class Pro26 {
    public static void main(String[] args) {
        System.out.println(Pro26.removeDuplicates(new int[]{1, 2, 2, 3, 4, 4, 5, 6, 6, 6, 7}));
        System.out.println(Pro26.removeDuplicates(new int[]{1, 1, 2}));
    }

    public static int removeDuplicates(int[] nums) {
        int slow = 0;
        int fast = 1;

        for (; slow < nums.length - 1 && fast < nums.length; fast++) {
            if (nums[slow] != nums[fast]) {
                nums[slow + 1] = nums[fast];
                slow++;
            }
        }

        return slow + 1;
    }
}
